package cn.tedu.spring.iocxml;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserTest {

    //1.测试bean对象的创建及根据id属性值获取bean对象
    @Test
    public void idTest(){
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        User user = (User) context.getBean("user");
        user.run();
    }
    @Test
    public void classTest(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        User user=(User) context.getBean(User.class);
        user.run();
    }
    @Test
    public void idClassTest(){
        ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        User user=(User) context.getBean("user",User.class);
        user.run();
    }
}
